package com.eastcom.collection.process
import com.eastcom.collection.provider.*
import com.eastcom.collection.context.*
import org.apache.commons.logging.Log
import org.apache.commons.logging.LogFactory
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor
import org.springframework.stereotype.Component

import javax.annotation.Resource

@Component("serverDestroyProcess")
public class ServerDestroyProcess {
	private static Log logger = LogFactory.getLog(ServerDestroyProcess.class);
	@Resource(name = "threadPool")
	private ThreadPoolTaskExecutor threadPoolTaskExecutor;
	public void stop(){
		Binding binding = new Binding()
		binding.setVariable("flag","stopDerbyDataBase")
		GroovyShell shell = new GroovyShell(binding)
		String serverShell = PropertyPlaceholderConfigurerProvider.getContextProperty("server_shell")
		if(serverShell != null){
			Script script = shell.parse(new File(serverShell))
			script.run()
		}
		TaskDestroyProcess taskDestroyProcess = SpringContextProvider.getBean("taskDestroyProcess");
		List path = ServerContext.scriptFilePath
		taskDestroyProcess.stop(path);
	}

}
